import * as TYPES from "../action-types";
import { Map } from "immutable";
let initState = Map({
  categories: [],
  currentId: 0,
  recommends: [],
  radios: [],
  total: 0,
});
function djradio(state = initState, action) {
  const { type, payload } = action;
  switch (type) {
    case TYPES.RAD_CATEGORIES:
      return state.set("categories", payload);
    case TYPES.RAD_CHANGE_ID:
      return state.set("currentId", payload);
    case TYPES.RAD_RECOMMENDS:
      return state.set("recommends", payload);
    case TYPES.RAD_RADIOS:
      const { djRadios, count } = payload;
      return state.set("radios", djRadios).set("total", count);

    default:
      return state;
  }
}

export default djradio;
